package com.jia.leetCode;

/**
 * 1491. 去掉最低工资和最高工资后的工资平均值
 */
public class Pro1491 {
    public double average(int[] salary) {
        if(salary.length < 3) return 0.0;
        int min = salary[0];
        int max = salary[0];
        int sum = 0;
        for(int s : salary) {
            min = Math.min(s, min);
            max = Math.max(s, max);
            sum += s;
        }
        return (sum - min - max) * 1.0 / (salary.length - 2);
    }
}
